﻿<?php 
session_start();
if ($_session['user_guid'] == "" || $_session['user_guid'] == null)
{
//	header("Location:login.php");
}
require_once '../bin/DBA/DB.class.php';
require_once '../bin/DAL/CategoriesDAL.php';
require_once '../bin/BLL/CategoriesBLL.php';
$categories = CategoriesBLL::GetItemByChs_Categories();
print_r($categories);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>无标题页</title>
    <link href="../Files/Css/formpost.css" rel="stylesheet" charset="utf-8" type="text/css" />
    <link href="../Files/Css/products.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="../Files/Javascript/jquery.js"></script>

    <script type="text/javascript" src="../Tools/tinymce/tinymce/tiny_mce.js"></script>

    <script language="javascript" type="text/javascript" src="../Tools/tinymce/editer.js"></script>

    <script type="text/javascript">
        jQuery(function($) {
            $(".content .main .record:last").addClass("nobor");
        });
    </script>

    <script type="text/javascript">
    //<![CDATA[
    $(function(){
            //����Ǳ���ģ���Ӻ��Ǳ�ʶ.
            $("form :input.required").each(function(){
                var $required = $("<strong class='high'> *</strong>"); //����Ԫ��
                $(this).parent().append($required); //Ȼ����׷�ӵ��ĵ���
            });
             //�ı���ʧȥ�����
            $('form :input').blur(function(){
                 var $parent = $(this).parent();
                 $parent.find(".formtips").remove();
                 //��֤��������
                 if( $(this).is('#txt_chsName') ){
                        if( this.value=="" ){
                            var errorMsg = '请输入分类中文名称.';
                            $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                        }else{
                            var okMsg = '输入正确.';
                            $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
                        }
                 }
                 //��֤Ӣ������
                 if( $(this).is('#txt_engName') ){
                    if( this.value=="" ){
                          var errorMsg = '请输入分类英文名称.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }else{
                          var okMsg = '输入正确.';
                          $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
                    }
                 }
                 //��֤��������
                 if( $(this).is('#txt_deuName') ){
                    if( this.value=="" ){
                          var errorMsg = '请输入分类德文名称.';
                          $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
                    }else{
                          var okMsg = '输入正确.';
                          $parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
                    }
                 }
            }).keyup(function(){
               $(this).triggerHandler("blur");
            }).focus(function(){
                 $(this).triggerHandler("blur");
            });//end blur

            
            //�ύ��������֤��
             $('#btnSubmit').click(function(){
                    $("form :input.required").trigger('blur');
                    var numError = $('form .onError').length;
                    if(numError){
                        return false;
                    }
             });
    })
    //]]>
    </script>

</head>
<body>
    <form id="form1" method="post" action="ModCategories.server.php">
    <div class="container">
        <div class="content">
            <div class="main">
                <div class="mid">
                    <div class="mid_title">
                        <ul class="mid_font">
                            <li>添加分类</li>
                        </ul>
                    </div>
                    <div class="mid_content">
                        <table width="100%">
                            <tr>
                                <td style="width: 15%">
                                    中文名称
                                </td>
                                <td align="left">
                                    <input id="txt_chsName" name="txt_chsName" type="text" class="required" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 15%">
                                    英文
                                </td>
                                <td align="left">
                                    <input id="txt_engName" name="txt_engName" type="text" class="required" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 15%">
                                    德文
                                </td>
                                <td align="left">
                                    <input id="txt_deuName" name="txt_deuName" type="text" class="required" />
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 15%">
                                    提交
                                </td>
                                <td align="left">
                                    <input id="btnSubmit" type="submit" value="添加分类" />
                                </td>
                            </tr>
                        </table>
                    </div>
                </div>
                <div class="mid">
                    <div class="mid_title">
                        <ul class="mid_font">
                            <li>分类管理</li>
                        </ul>
                    </div>
                    <div class="mid_content">
                        <table width="100%"  frame="border" rules="all">
                            <tr>
                                <td style="width: 30%">
                                    分类名称
                                </td>
                                <td>
                                    操作
                                </td>
                            </tr>
                            <?php
                             for ($i=0;$i<count($categories);$i++){
                             ?>
                            <tr>
                                <td style="width: 30%">
                                <?php echo $categories[$i]['name'];?>
                                </td>
                                <td>
                                    <a href="EditCategorie.php?guid=<?php echo $categories[$i]['guid']?>">修改</a>|<a href="DelCategories.server.php?guid=<?php echo $categories[$i]['guid']?>">删除</a>
                                </td>
                            </tr>
                            <?php }?>
                        </table>
                    </div>
                </div>
            </div>
        </div>
        <div id="clear">
        </div>
    </div>
    </form>
</body>
</html>